import { Component } from '@angular/core';
import { NavController, IonicPage } from 'ionic-angular';
import { HttpClient } from '@angular/common/http';
import { HttpProvider } from '../../providers/http/http';
import { ApiProvider } from '../../providers/api/api';

@IonicPage({
  name: 'home',
  segment: 'home'
})
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  public data: any = [];
  constructor(
    public navCtrl: NavController,
    public http: HttpClient,
    public _http: HttpProvider,
    public _api: ApiProvider
    ) {
      this.getData();
  }
  // 商品详细页面
  goDetail(item) {
    this.navCtrl.push('pay',item);
  }
  getData() {
    // this.http.get('../../assets/json/home.json').subscribe(res => {
    //   console.log(res);
    // })
    // let header :any = {'token': 'xxxxxxxxxxxxx'}

    // this._http.request('GET','../../assets/json/home.json').subscribe(res => {
    //   console.log(res);
    //   this.data = res.data;
    // }, error => {
    //   console.log(error);
    // })

    this._api.getHome().subscribe(res=> {
      console.log(res);
      this.data = res.data;
    })
  }
}
